android.device
Class PiccManager

java.lang.Object
  extended by android.device.PiccManager

public class PiccManager
extends java.lang.Object

模块: POS非接触式卡
版本号: v2.2.3
更新时间: 2015/10/16
v2.2.2 2015/10/16 增加纯CPU卡(如Desfire Card)发送apdu指令的接口: apduTransmit(byte[] sent, int sentlen, byte[] rsp);
特别说明:
本类仅用于POS类设备。


Constructor Summary
PiccManager()
           
 
Method Summary
 int activate()
          activate card to start sending APDU。
 int antisel(byte[] sn, byte[] sak)
          anti-collision and select card and returns the serial number of the card
 int apduTransmit(byte[] sent, int sentlen, byte[] rsp)
          Transmit APDU exchange commands:e.g.
 int apduTransmit(byte[] cmd, int cmdlen, byte[] rsp, byte[] sw)
          Transmit APDU commands
 int close()
          Close the PICC reader
 int deactivate(byte mode)
          Deavtivate a card
 int m1_amount(int blkNo)
          read the amount for the block number
 int m1_decrement(int blkNO, int iMoney)
          decrement the value block by iMoney amount
 int m1_increment(int blkNo, int iMoney)
          increment the value block by iMoney amount
 int m1_init(int blkNo, int value)
          init the value block by value
 int m1_keyAuth(int keyType, int blnNo, int keylen, byte[] keyBuf, int iSeriNumlen, byte[] seriNum)
          authenticate a key
 int m1_readBlock(int blkNo, byte[] pReadBuf)
          To read a block
 int m1_restore(int blkNo)
          Move the content of a block into temporary data register
 int m1_transfer(int blkNo)
          transfer from temporary internal data register to value block
 int m1_writeBlock(int blkNo, int iLenWriteBuf, byte[] pWriteBuf)
          Write a block into the card
 int open()
          Open the PICC reader
 int request(byte[] mode, byte[] atq)
          Request card
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PiccManager

public PiccManager()
Method Detail

open

public int open()
Open the PICC reader

Returns:
0 if successful, and negative number if failed

request

public int request(byte[] mode,
                   byte[] atq)
Request card

Parameters:
mode - returns the card type, could be 'A' or 'B'
atq - returns the ATQ
Returns:
length of ATQ

antisel

public int antisel(byte[] sn,
                   byte[] sak)
anti-collision and select card and returns the serial number of the card

Parameters:
sn - serial number
sak - SAK
Returns:
length of sn,negative number if failed

activate

public int activate()
activate card to start sending APDU。(skip this call for M1 card).

Returns:
0 if successful, negative number if failed

apduTransmit

public int apduTransmit(byte[] cmd,
                        int cmdlen,
                        byte[] rsp,
                        byte[] sw)
Transmit APDU commands

Parameters:
cmd - APDU command to be sent, the command format with ISO7816 Transmission protocol
cmdlen - APDU length
rsp - Response from card
sw - status bytes
Returns:
The APDU length. Negative number if failed

apduTransmit

public int apduTransmit(byte[] sent,
                        int sentlen,
                        byte[] rsp)
Transmit APDU exchange commands:e.g. Desfire Card

Parameters:
cmd - APDU command to be sent
cmdlen - APDU length
rsp - Response from card
Returns:
The APDU length. Negative number if failed

deactivate

public int deactivate(byte mode)
Deavtivate a card

Parameters:
mode - 0x00 imply HALT, deactivate card and return without checking for card removal. 0x01 imply REMOVE, deactivate card and check for card removal; 0x02 imply EMV compliant card removal, and check for card removal.
Returns:
0 if successful, negative number if failed

close

public int close()
Close the PICC reader

Returns:
0 if successful, negative number if failed

m1_keyAuth

public int m1_keyAuth(int keyType,
                      int blnNo,
                      int keylen,
                      byte[] keyBuf,
                      int iSeriNumlen,
                      byte[] seriNum)
authenticate a key

Parameters:
keyType - key type: 0 means A key, 1 means B key
blnNo - block number
keylen - key length
keyBuf - the key
iSeriNumlen - serial number length
seriNum - serial number
Returns:
0 if successful, negative number if failed

m1_readBlock

public int m1_readBlock(int blkNo,
                        byte[] pReadBuf)
To read a block

Parameters:
blkNo - block number
pReadBuf - to store the read data
Returns:
0 if successful, negative number if failed

m1_writeBlock

public int m1_writeBlock(int blkNo,
                         int iLenWriteBuf,
                         byte[] pWriteBuf)
Write a block into the card

Parameters:
blkNo - the block number
iLenWriteBuf - length of buffer to be written
pWriteBuf - the buffer to be written
Returns:
0 if successful, negative number if failed

m1_increment

public int m1_increment(int blkNo,
                        int iMoney)
increment the value block by iMoney amount

Parameters:
blkNo - the value block number
iMoney - the amount to be decremented
Returns:
0 if successful, negative number if failed

m1_decrement

public int m1_decrement(int blkNO,
                        int iMoney)
decrement the value block by iMoney amount

Parameters:
blkNO - the value block number
iMoney - the amount to be decremented
Returns:
0 if successful, negative number if failed

m1_restore

public int m1_restore(int blkNo)
Move the content of a block into temporary data register

Parameters:
blkNo - the block number to be operated on
Returns:
0 if successful, negative number if failed

m1_transfer

public int m1_transfer(int blkNo)
transfer from temporary internal data register to value block

Parameters:
blkNo - the block number to be operated on
Returns:
0 if successful, negative number if failed

m1_init

public int m1_init(int blkNo,
                   int value)
init the value block by value

Parameters:
blkNo - the value block number
value - the amount to be init
Returns:
0 if successful, negative number if failed

m1_amount

public int m1_amount(int blkNo)
read the amount for the block number

Parameters:
blkNo - the value block number
Returns:
The amount. Negative number if failed